<template>
	<view class="container">
		<view class="content">
			
			<view>
				<view v-if="popularList.length===0" style="color: #CCCCCC;text-align: center;width: 100%;height: 500upx;line-height: 500upx;font-size: 32upx;"> 暂无数据</view>

				<view v-else class="container">
					<view  class="un-top1" ></view>
					<view class="un-top" id="tu2">
						<image :src="img1" mode="aspectFill"></image>
					</view>
					<view class="guess-section">
						<view 
							v-for="(item, index) in popularList" :key="index"
							class="guess-item"
							@click="navToDetailPage(item)"
						>
							<view class="un-renimage-wrapper">
								<image :src="img+item.THUMB" mode="aspectFill"></image>
							</view>
							<text class="un-rentitle clamp">{{item.NAME}}</text>
							<text class="un-rentit2 title2 clamp">{{item.SHORTINFO}}</text>
							<text class="un-renprice" v-if="!item.MULTIPAY">¥{{item.SALEPRICE}}</text>
							
							<text class="un-renprice" v-if="item.MULTIPAY==2&&item.OPPOINT!=0">积分{{item.OPPOINT}}</text>
							<text class="un-renprice" v-if="item.MULTIPAY==2&&item.OPDEDU!=0">抵扣券{{item.OPDEDU}}</text>
							<text class="un-renprice" v-if="item.MULTIPAY==2&&item.OPCOUPON!=0">惠券{{item.OPCOUPON}}</text>
							
							<text class="un-renprice" v-if="item.MULTIPAY==3&&item.MUCHSELLERPRICE!=0">{{item.MUCHSELLERPRICE}}元</text>
							<text class="un-renprice" v-if="item.MULTIPAY==3&&item.MUCHSELLERPRICE!=0&&item.MPPOINT!=0">+</text>
							<text class="un-renprice" v-if="item.MULTIPAY==3&&item.MPPOINT!=0">积分{{item.MPPOINT}}</text>
							<text class="un-renprice" v-if="item.MULTIPAY==3&&(item.MUCHSELLERPRICE!=0||item.MPPOINT!=0)&&item.MPDEDU!=0">+</text>
							<text class="un-renprice" v-if="item.MULTIPAY==3&&item.MPDEDU!=0">抵扣券{{item.MPDEDU}}</text>
							<text class="un-renprice" v-if="item.MULTIPAY==3&&(item.MUCHSELLERPRICE!=0||item.MPPOINT!=0||item.MPDEDU!=0)&&item.MPCOUPON!=0">+</text>
							<text class="un-renprice" v-if="item.MULTIPAY==3&&item.MPCOUPON!=0">惠券{{item.MPCOUPON}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import uniSegmentedControl from '@/components/uni-segmented-control/uni-segmented-control.vue';
	import slFilter from '@/components/sl-filter/sl-filter.vue';
	export default {
		components: {
			uniSegmentedControl,
			slFilter
		},
		data() {
			return {
				img:'',
				img1:'',//兑换商品顶部图片
				popularList:[],
				gp:0
			}
		},
		onLoad(option) {
			uni.setNavigationBarTitle({
			    title:option.title
			}),
			this.gp = option.labelId
			this.img = getApp().globalData.imageAddress
			this.img1 = this.img+'/top/new.jpg'
			this.loadData();
			uni.startPullDownRefresh();
		},
		onPullDownRefresh() {
			console.log('refresh');
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		
		methods: {
			async loadData() {
					//加载信息
				this.$http.post("/goods/exchange",{
					SIGNATURE : uni.getStorageSync("SIGNATURE"),
					LID: this.gp
				}).then((e)=>{
					this.popularList = e.data.OBJECT
					console.log(">>>>>>>>>>>",this.popularList);
				}).catch((err)=>{
					console.log("请求超时",err);
				})
			},
			//跳转商品详情页
			navToDetailPage(item) {
				console.log(item);
				let ids=item.ID;
				let sid=item.SID;
				uni.navigateTo({
					url: `/pages/product/productExchange?id=${ids}&sid=${sid}`
				})
			},
		}
	}
</script>

<style lang="scss">
	page{
		background-color: #F5F5F5;
	}
	.un-top{
		// margin-top: 82upx;
		width: 100%;
		height: 310upx;
		background: #fff;
		image{
			width:100%;
			height: 100%; 
		}
	}
	.un-tiao1{
		
		width: 100%;
		height: 100%; 
		z-index: 1;
	}
	.un-tiao2{
		top: 155upx;
		position: fixed;
		width: 100%;
		height: 100%; 
		z-index: 2;
	}
	.guess-section{
		display:flex;
		flex-wrap:wrap;
		// background: #fff;
		.guess-item{
			background: #fff;
			margin-top: 5upx;
			margin-left: 15upx;
			
			position: relative;
			text-align: center;
			flex-direction: column;
			width: 47%;
			
		}
		.un-renimage-wrapper{
			
			width: 350upx;
			height: 370upx;
			border-radius: 3px;
			overflow: hidden;
			image{
				width: 100%;
				height: 100%;
				opacity: 1;
			}
		}
		.un-rentitle{
			margin-left: 40upx;
			font-size: 22upx;
			color: $font-color-dark;
			line-height: 50upx;
		}
		.un-renprice{
			font-size: 22upx;
			color: $uni-color-primary;
			line-height: 1;
			line-height: 50upx;
		}
		.un-rentit2{
			margin-left: 40upx;
			font-size: 22upx;
			color: $font-color-light;
			line-height: 25upx;
		}
		.un-huangtuoyuan{
			z-index: 1;
			position: absolute;
			margin-left: 180upx;
			margin-bottom: 200upx;
			top: -18upx;
			right: 20upx;
			width: 79upx;
			height: 35upx;
			background: inherit;
			background-color: rgba(241, 151, 54, 1);
			box-sizing: border-box;
			border-width: 1upx;
			border-style: solid;
			border-color: rgba(241, 151, 54, 1);
			border-radius: 42upx;
			border-bottom-left-radius: 0upx;
			-moz-box-shadow: none;
			-webkit-box-shadow: none;
			box-shadow: none;
			font-family: '微软雅黑';
			font-weight: 404;
			font-style: normal;
			font-size: 22upx;
			color: #FFFFFF;
			text-align: center;
			line-height: 31upx
		}
	}
</style>
